19. Solutions: ORDER BY
Solutions to previous ORDER BY questions
- Write a query to return the 10 earliest orders in the orders table. Include the
id
,occurred_at
, andtotal_amt_usd
.
SELECT id, occurred_at, total_amt_usd
FROM orders
ORDER BY occurred_at
LIMIT 10;
- Write a query to return the top 5 orders in terms of largest
total_amt_usd
. Include theid
,account_id
, andtotal_amt_usd
.
SELECT id, account_id, total_amt_usd
FROM orders
ORDER BY total_amt_usd DESC
LIMIT 5;
- Write a query to return the lowest 20 orders in terms of smallest
total_amt_usd
. Include theid
,account_id
, andtotal_amt_usd
.
SELECT id, account_id, total_amt_usd
FROM orders
ORDER BY total_amt_usd
LIMIT 20;
Workspace
This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity, so you may be able to download them there.
Workspace Information:
- Default file path:
- Workspace type: sql-evaluator
- Opened files (when workspace is loaded): n/a